﻿@inherits BasePlugin
@rendermode InteractiveServer

@namespace FluentCMS.Web.Plugins.Admin.ContentTypeManagement

<PluginBody Title="Content Types">
    <ActionsFragment>
        <ActionButtonCreate Href="@GetUrl("Create ContentType")" Label="New Content Type" />
    </ActionsFragment>
    <ChildContent>
        <DataTable Items="ContentTypes">
            <DataTableItem Label="Slug">
                @context.Slug
            </DataTableItem>
            <DataTableItem Label="Title">
                @context.Title
            </DataTableItem>
            <DataTableItem Label="Description">
                @context.Description
            </DataTableItem>
            <DataTableItem Label="Fields">
                @(context.Fields?.Count ?? 0)
            </DataTableItem>
            <ActionButtons>
                <ActionButtonEdit Href="@GetUrl("Update ContentType", new { id = @context.Id })" />
                <ActionButton IconName="IconName.Eye" Color="Color.Success" Label="Fields" Href="@GetUrl("View ContentType", new { id = @context.Id })" />
                <ActionButton IconName="IconName.PenNib" Color="Color.Secondary" Label="Contents" Href="@GetUrl("Contents List", new { slug = @context.Slug })" />
                <ActionButtonDelete @onclick="() => OnConfirm(context.Id)" />
            </ActionButtons>
        </DataTable>
    </ChildContent>
</PluginBody>

<Confirm OnConfirm="OnDelete" OnCancel="OnConfirmClose" Visible="SelectedContentTypeId != null">
    Are you sure to delete this content type?
</Confirm>
